import * as verify from './verify'

export * from './verify'
export * from './validates'


interface IVerify {
    [key:string]:any
}

export const validatorCustom = (name: string) => {
    return (rule: any, value: any, callback: any) => {
        if (!value) {
            callback()
        }
        const verifyFn = (<IVerify>verify)[name];
        if (!verifyFn(value)) {
            callback(new Error(rule.message))
        } else {
            callback()
        }
    }
}